package com.jimmieran.myshopinventoryservice.myshopinventoryservice.mapper;

import com.jimmieran.myshopinventoryservice.myshopinventoryservice.model.ProductInventory;
import org.apache.ibatis.annotations.*;


@Mapper
public interface ProductInventoryMapper {
	
	@Insert("INSERT INTO product_inventory(value,product_id) VALUES(#{value},#{productId})")
	@Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
	public void add(ProductInventory productInventory);
	
	@Update("UPDATE product_inventory SET value=#{value},product_id=#{productId} WHERE id=#{id}")  
	public void update(ProductInventory productInventory);
	
	@Delete("DELETE FROM product_inventory WHERE id=#{id}")  
	public void delete(Long id);
	
	@Select("SELECT * FROM product_inventory WHERE id=#{id}")
	@Results({
			@Result(column = "product_id", property = "productId")
	})
	public ProductInventory findById(Long id);
	
}
